using System.IO;

namespace Framework.Core.Process.Tasks
{
    internal static class ProcessTaskExtension
    {
        public static string Deploy(this string exePath)
        {
            var stream = typeof(ProcessTaskExtension).Assembly.GetManifestResourceStream(string.Format("Framework.Core.Process.Tasks.{0}", Path.GetFileName(exePath)));

            using (var fileStream = File.Open(exePath, FileMode.Create, FileAccess.Write))
            {
                // ReSharper disable PossibleNullReferenceException
                stream.CopyTo(fileStream);
                // ReSharper restore PossibleNullReferenceException
            }

            return Path.GetFileNameWithoutExtension(exePath);
        }
    }
}